18. WorkManager for the background
L9 36 What Is The Background V1
Are you a friend of the battery?
SOLUTION:
- Use WorkManager.
- Specify as many reasonable constraints as possible for each job, such as device idle, charging, and connected to wifi.
- Be sparing about scheduling background work - if the work can wait until next launch then do it when the app is in the foreground.
- When scheduling work that happens periodically, use the largest delay possible between each run.
- Make sure your background jobs are efficient and don't use excessive network, CPU, or disk access.
Reference documentation